<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="css/eye.css">
    <script src="jquery-3.6.0.min.js"></script>
</head>

<body>
    <div class="box">
        <label>
          <img src="images/close.png" id="eye">
        </label>
        <input type="password" id="pwd">
    </div>

    <script>
        $(function() {
            var flag = 0;
            $("img").on("click", function() {
                if (flag == 0) {
                    $("input").prop("type", "text");
                    $("img").prop("src", "images/open.png")
                    flag = 1;
                } else {
                    $("input").prop("type", "password");
                    $("img").prop("src", "images/close.png")
                    flag = 0;
                }

            })
        })
    </script>
</body>

</html>